package ru.alt22.visor.php.ui.commands;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import org.eclipse.jface.action.IAction;

abstract public class CreateTypeCommand implements IHandler {

	protected IAction action;

	public CreateTypeCommand() {
		action = null;
	}

	public void addHandlerListener(IHandlerListener handlerListener) {
	}

	public void dispose() {
		action = null;
	}

	public Object execute(ExecutionEvent event) throws ExecutionException {
		if (action == null) {
			createAction(); 
		}
		updateAction();
		action.run();
		return null;
	}

	abstract protected void createAction();

	protected void updateAction() {
	}

	public boolean isEnabled() {
		return true;
	}

	public boolean isHandled() {
		return true;
	}

	public void removeHandlerListener(IHandlerListener handlerListener) {
	}

}